package com.mao;

public class ArrayTest4 {
    public static void main(String[] args) {
        // 目标：完成斗地主游戏的做牌和洗牌
        start();
    }
    public static void start(){
        String[] poker = new String[54];
        // porker = [null, null, ...]
        //准备四种花色，还有点色，再开始做牌
        String[] colors = {"♠","♥","♣","♦"};//j
        String[] points = {"3","4","5","6","7","8","9","10","J","Q","K","A","2"};//i

        //先遍历点数，在遍历花色
        int index = 0;
        for (int i = 0; i < points.length; i++) {
            for(int j = 0; j < colors.length; j++)
            {
                // 把点数和花色拼接，放到数组中
                poker[index] = colors[j]+points[i];
                index++;
            }
        }
        // 将大小王存入数组
        poker[index++] = "🃏";
        poker[index++] = "👲";

        //打印牌
        System.out.println("新牌：");
        for (int i = 0; i < poker.length; i++) {
            if(i!=0 && (i%4 == 0)) System.out.println();

            System.out.print(poker[i]+" ");
        }
        System.out.println();
        System.out.println("洗牌：");
        for (int i = 0; i < 100; i++) {
            int i1 = (int)(Math.random()*poker.length);
            int i2 = (int)(Math.random()*poker.length);
            String temp = poker[i1];
            poker[i1] = poker[i2];
            poker[i2] = temp;
        }
        for (int i = 0; i < poker.length; i++) {
            if(i!=0 && (i%10 == 0)) System.out.println();
            System.out.print(poker[i]+" ");
        }
        System.out.println();
    }
}
